/**
 * 报价 api 封装
 */
import {getRequest, postRequest, request} from '/@/lib/axios';

export const STATUS = {
    10: '待上门取件',
    11: '物流运输中',
    12: '到货待质检',
    13: '质检中',
    20: '揽件前取消',
    21: '待退回',
    22: '已退回',
    30: '待确认交易',
    31: '待打款',
    32: '打款失败',
    33: '交易完成',
    88: '异常关闭',
};
export const CHECKSTATUS = {
    1: '质检中断',
    2: '质检完成',
    3: '待继续质检',
    4: '无法质检',
}
export const QUALITYSTATUS = {
    11: '质检结果与评估一致',
    12: '质检结果与评估存在差异',
    13: '一单多机',
    14: '不支持回收',
}
export const QUALITYSTATUSALL = {
    11: '质检结果与评估一致',
    12: '质检结果与评估存在差异',
    13: '一单多机',
    14: '不支持回收(需要退)',
    15: '不支持回收(不需要退)',
}
export const orderApi = {

    /**
     * 分页查询
     */
    queryPage: (param) => {
        return postRequest('/order/queryPage', param);
    },
    /**
     * 增加
     */
    add: (param) => {
        return postRequest('/order/add', param);
    },

    /**
     * 修改
     */
    update: (param) => {
        return postRequest('/order/update', param);
    },

    /**
     * 删除
     */
    delete: (id) => {
        return getRequest(`/order/delete/${id}`);
    },

    /**
     * 订单详情
     */
    detail: (id) => {
        return getRequest(`/order/detail/${id}`);
    },
    /**
     * 用户评估详情
     */
    evaluateDetail: (id) => {
        return getRequest(`/order/eval/${id}`);
    },
    /**
     * 编辑收款信息
     */
    editPayee: (id, param) => {
        return postRequest(`/order/payInfo/${id}`, param);
    },
    /**
     * 取消订单
     */
    cancelOrder: (id) => {
        return request({
            url: `/order/${id}`,
            method: 'DELETE'
        });
    },
    /**
     * 跟进
     * {
     *   "bak": "string",
     *   "orderId": 0
     * }
     */
    track: (param) => {
        return postRequest(`/order/dymic/`, param);
    },
    /**
     * 获取跟进列表
     */
    getTrackList: (id) => {
        return getRequest(`/order/dymic/${id}`);
    },
    /**
     * 绑定质检师
     */
    bindChecker: (id) => {
        return postRequest(`/check/pre/${id}`);
    },
    /**
     * 添加机器质检
     */
    addDevice: (data) => {
        return postRequest(`/check/add`, data);
    },
    /**
     * 质检修改
     */
    updateDevice: (data) => {
        return postRequest(`/check/update`, data);
    },
    /**
     * 添加机器质检
     */
    deleteCheckDevice: (id) => {
        return request({
            url: `/check/${id}`,
            method: 'DELETE'
        });
    },
    /**
     * 推送质检报告
     * checkResultFlag11：机况一致 12：机况存在差异 13：一单多机 14：非回收品类(需要退) 15：非回收品类(不需要退)
     * orderId
     */
    pushCheckReport: (data) => {
        return postRequest(`/check/push`, data);
    },
    /**
     * 质检详情
     */
    getCheckDeviceDetail: (id) => {
        return getRequest(`/check/detail/${id}`);
    },
    /**
     * 订单已添加质检的机器
     */
    orderCheckedDevices: (id) => {
        return getRequest(`/check/list/${id}`);
    },
    /**
     * 申请再次打款
     */
    payAgain: (id) => {
        return postRequest(`/order/payAgain/${id}`, {});
    },
    /**
     * 获取质检模版
     */
    getCheckModel: () => {
        return postRequest(`/check/model`, {});
    },
    /**
     * 获取快递轨迹信息
     */
    getExpressTrack: (param) => {
        return getRequest(`/order/sf/route/`,param);
    },
    /**
     * 获取下单用户地址
     */
    getOrderUserAddress: (id) => {
        return getRequest(`/order/userAddress/${id}`, {});
    },
    /**
     * 拒绝回收编辑退货地址
     */
    rejectRecycle: (id,statusBack,param) => {
       const url = statusBack?`/order/backInfo/${id}`:`/order/backSell/${id}`
        return postRequest(url, param);
    },
    /**
     * 确认回收
     */
    confirmRecycle: (id) => {
        return postRequest(`/order/sureSell/${id}`, {});
    },

    /**
     * 查询质检表格
     */
    queryCheckPage: (param) => {
        return postRequest('/order/check/queryPage', param);
    },

    /**
     * 退回生成出库单
     */
    generateDeliveryForBack: (id,freightFlag) => {
        return postRequest(`/order/createDelivery/${id}?freightFlag=${freightFlag}`,{});
    },

};
